package com.boot.controller;

import com.boot.entity.Book;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

@RestController
@RequestMapping({"book"})
@Slf4j
public class BookController {

    @RequestMapping({"list"})
    public List<Book> list() {
        List<Book> books = new ArrayList<Book>() {{
            add(Book.builder()
                    .id(UUID.randomUUID().toString())
                    .name("三国演戏")
                    .price(56)
                    .describe("战争军事书籍")
                    .build());

            add(Book.builder()
                    .id(UUID.randomUUID().toString())
                    .name("水浒传")
                    .price(60)
                    .describe("英雄豪情")
                    .build());

            add(Book.builder()
                    .id(UUID.randomUUID().toString())
                    .name("西游记")
                    .price(80)
                    .describe("神话故事")
                    .build());

            add(Book.builder()
                    .id(UUID.randomUUID().toString())
                    .name("红楼梦")
                    .price(66)
                    .describe("三大家族豪门衰败史")
                    .build());

            add(Book.builder()
                    .id(UUID.randomUUID().toString())
                    .name("史记")
                    .price(88)
                    .describe("历史记录")
                    .build());
        }};
        return books;
    }
}
